<#include "/common/head.ftl">

<@showTitle title="${i18n.getMessage('offering')} > ${i18n.getMessage('info')}">
	<ul class="linksMenu">
		<li><a href="#" onclick="cc('study/showListOfferingMember.sgt?offeringId=${offering.id}')">${i18n.getMessage('student.list')}</a></li>
		<li>-</li>
		<li class="sub"><a href="#">${i18n.getMessage('printing')}</a>
			<ul>
				<li><a href="#" onclick="printFollowUpBookCover()">${i18n.getMessage('printing.followUpCover')}</a></li>
				<li><a href="#" onclick="printStudentPerformanceForm()">${i18n.getMessage('printing.studentPerformance')}</a></li>
				<li><a href="#" onclick="exportSpeakingTestForm()">${i18n.getMessage('export.speakingTest')}</a></li>
				<#if offering.level.program.programType == "CHILDREN">
				<li><a href="#" onclick="exportCambridgeTestForm()">${i18n.getMessage('export.cambridgeTest')}</a></li>
				</#if>
			</ul>
        </li>
        <li>-</li><li><a href="#" onclick="cc('offering/showInfoAttendance.sgt?offeringId=${offering.id}')">${i18n.getMessage('attendance')}</a></li>
        <li>-</li><li><a href="#" onclick="cc('teacher/showCheckingAttendance.sgt?offeringId=${offering.id}')">${i18n.getMessage('teaching')}</a></li>
        <li>-</li><li><a href="#" onclick="cc('study/showTestResult.sgt?offeringId=${offering.id}')">${i18n.getMessage('result')}</a></li>
        <li>-</li><li><a href="#" onclick="cc('offering/showListOpinion.sgt?offeringId=${offering.id}')">${i18n.getMessage('opinion')}</a></li>
        <li>-</li><li><a href="#" onclick="cc('offering/showListTeachingInterruption.sgt?offeringId=${offering.id}')">${i18n.getMessage('substitution')}</a></li>
        <li>-</li><li><a href="#" onclick="cc('offering/showListTeachingSwitch.sgt?offeringId=${offering.id}')">${i18n.getMessage('transfer')}</a></li>
        <li>-</li><li><a href="#" onclick="cc('offering/showListVideoSchedule.sgt?offeringId=${offering.id}')">${i18n.getMessage('video')}</a></li>
        <li>-</li><li><a href="#" onclick="cc('offering/showListTestSchedule.sgt?offeringId=${offering.id}')">${i18n.getMessage('test')}</a></li>
        <#if nextOffering??>
        	<li>-</li><li><a href="#" onclick="cc('offering/showEditNextOffering.sgt?offeringId=${offering.id}')">${i18n.getMessage('nextOffering')}</a></li>
        <#else>
        <li>-</li><li><a href="#" onclick="cc('offering/showAddNextOffering.sgt?offeringId=${offering.id}')">${i18n.getMessage('nextOffering')}</a></li>
        </#if>
        <li>-</li><li><a href="#" onclick="if(confirm('${i18n.getMessage('dialog.delete')}')) { cc('offering/deleteOffering.sgt?id=${offering.id}'); }">${i18n.getMessage('delete')}</a></li>
	</ul>
</@showTitle>
<br/>

<div id="error" style="display:none"></div>

<form id="form" action="offering/editOffering.sgt" validator="offering/validateOffering.sgt" onsubmit="submitFormValidation(this); return false;" onreset="$('error').hide()">
	<input type="hidden" name="id" value="${offering.id}"/>
	<input type="hidden" name="version" value="${offering.version}"/>
	
	<fieldset class="fs">
		<legend>Initial Info</legend>
		<table id="dataTable" cellspacing="5" cellpadding="0" align="center" style="width: 100%">
			<tr>
				<td class="name1"><@required/>${i18n.getMessage('name')}:</td>
				<td>
					<input type="text" name="name" value="${(offering.name)!}" style="width:190px"/>
				</td>
				<td class="name3"><@required/>${i18n.getMessage('startDate')}:</td>
				<td>
					<input type="text" name="startDate" value="${(offering.startDate?date)!}" style="width:150px"/><img class="calendarImg" src="images/calendar/calendar.gif" onclick="displayCalendar(document.forms[0].startDate, '${i18n.getMessage('format.date')}', this)"/>
				</td>
			</tr>
			<tr>
				<td class="name1"><@required/>${i18n.getMessage('level')}:</td>
				<td>
					<select name="levelId" style="width:194px">
						<option></option>
							${request.setAttribute("levels", program.levels)}
							<optgroup label="${program.name}">
								<#list levels as level>
									<option value="${level.id}" <#if (offering.level = level)>selected</#if>>${level.name}</option>
								</#list>
							</optgroup>
					</select>
				</td>
				<td class="name3"><@required/>${i18n.getMessage('endDate')}:</td>
				<td>
					<input type="text" name="endDate" value="${(offering.endDate?date)!}" style="width:150px"/><img class="calendarImg" src="images/calendar/calendar.gif" onclick="displayCalendar(document.forms[0].endDate, '${i18n.getMessage('format.date')}', this)"/>
				</td>
			</tr>
			<tr>
				<td class="name1">${i18n.getMessage('room')}:</td>
				<td>
					<select name="roomId" style="width:194px">
						<option></option>
						<#list locations as location>
							${request.setAttribute("rooms", location.rooms)}
							<optgroup label="${location.name}">
								<#list rooms as room>
									<option value="${room.id}" <#if ((offering.room)! = room)>selected</#if>>${room.name}</option>
								</#list>
							</optgroup>
						</#list>
					</select>
				</td>
				<td class="name3"><@required/>${i18n.getMessage('shift')}:</td>
				<td>
					<select name="shiftId" style="width:174px">
						<option></option>
						<#list shifts as shift>
							<option value="${(shift.id)!}" <#if shift=(offering.shift)!>selected</#if>>${(shift.startTime?time)!}-${(shift.endTime?time)!}</option>
						</#list>
					</select>
				</td>
			</tr>
			
			<tr>
				<td class="name1">${i18n.getMessage('cancel')}:</td>
				<td>
					<input type="checkbox" name="cancel" value="true" <#if offering.cancel>checked</#if> />
				</td>
				<td class="name3"></td>
				<td></td>
			</tr>
		</table>
	</fieldset>
	<p>&nbsp;</p>
	<fieldset class="fs">
		<legend>Exam Dates</legend>
		<table id="dataTable" cellspacing="5" cellpadding="0" align="center" style="width: 100%">
			<tr>
				<td class="name1">${i18n.getMessage('midtermWrittenDate')}:</td>
				<td>
					<input type="text" name="midtermWrittenDate" value="${(offering.midtermWrittenDate?date)!}" style="width:140px"/><img class="calendarImg" src="images/calendar/calendar.gif" onclick="displayCalendar(document.forms[0].midtermWrittenDate, '${i18n.getMessage('format.date')}', this)"/>
				</td>
				<td class="name2">${i18n.getMessage('certificateIssueDate')}:&nbsp;</td>
				<td style="padding-left:8px;">
					<input type="text" name="issueDate" value="${(offering.issueDate?date)!}" style="width:150px"/><img class="calendarImg" src="images/calendar/calendar.gif" onclick="displayCalendar(document.forms[0].issueDate, '${i18n.getMessage('format.date')}', this)"/>
				</td>
			</tr>
			<tr>
				<td class="name1">${i18n.getMessage('finalSpokenDate')}:</td>
				<td>
					<input type="text" name="finalSpokenDate" value="${(offering.finalSpokenDate?date)!}" style="width:140px"/><img class="calendarImg" src="images/calendar/calendar.gif" onclick="displayCalendar(document.forms[0].finalSpokenDate, '${i18n.getMessage('format.date')}', this)"/>
				</td>
				<td class="name2">${i18n.getMessage('cambridgeSpokenDate')}:&nbsp;</td>
				<td style="padding-left:8px;">
					<input type="text" name="cambridgeSpokenDate" value="${(offering.cambridgeSpokenDate?date)!}" style="width:150px"/><img class="calendarImg" src="images/calendar/calendar.gif" onclick="displayCalendar(document.forms[0].cambridgeSpokenDate, '${i18n.getMessage('format.date')}', this)"/>
				</td>
			</tr>
			<tr>
				<td class="name1">${i18n.getMessage('finalWrittenDate')}:</td>
				<td>
					<input type="text" name="finalWrittenDate" value="${(offering.finalWrittenDate?date)!}" style="width:140px"/><img class="calendarImg" src="images/calendar/calendar.gif" onclick="displayCalendar(document.forms[0].finalWrittenDate, '${i18n.getMessage('format.date')}', this)"/>
				</td>
				<td class="name2">${i18n.getMessage('cambridgeWrittenDate')}:&nbsp;</td>
				<td style="padding-left:8px;">
					<input type="text" name="cambridgeWrittenDate" value="${(offering.cambridgeWrittenDate?date)!}" style="width:150px"/><img class="calendarImg" src="images/calendar/calendar.gif" onclick="displayCalendar(document.forms[0].cambridgeWrittenDate, '${i18n.getMessage('format.date')}', this)"/>
				</td>
			</tr>
		<tr>
			
		</tr>
		</table>
	</fieldset>
	<p>&nbsp;</p>
	<fieldset class="fs">
		<legend>Instructors</legend>
		<table id="dataTable" cellspacing="5" cellpadding="0" align="center" style="width: 100%">
		<tr>
			<td class="name1">${i18n.getMessage('monTeacher')}:</td>
			<td>
				<select name="monTeacherId" id="monTeacherId" style="width:204px">
					<option></option>
					<#list teachers as teacher>
						<option value="${teacher.id}" <#if teacher = (offering.monTeacher)!>selected</#if>>${(teacher.fullName)!}</option>
					</#list>
				</select>
			</td>
			<td class="ta">${i18n.getMessage('monTA')}:</td>
			<td>
				<select name="taMonTeacherId" id="taMonTeacherId" style="width:204px">
					<option></option>
				</select>
			</td>
		</tr>
		<tr>
			<td class="name">${i18n.getMessage('tueTeacher')}:</td>
			<td>
				<select name="tueTeacherId" id="tueTeacherId" style="width:204px">
					<option></option>
					<#list teachers as teacher>
						<option value="${teacher.id}" <#if teacher = (offering.tueTeacher)!>selected</#if>>${(teacher.fullName)!}</option>
					</#list>
				</select>
			</td>
			<td class="ta">${i18n.getMessage('tueTA')}:</td>
			<td>
				<select name="taTueTeacherId" id="taTueTeacherId" style="width:204px">
					<option></option>
				</select>
			</td>
		</tr>
		<tr>
			<td class="name">${i18n.getMessage('wedTeacher')}:</td>
			<td>
				<select name="wedTeacherId" id="wedTeacherId" style="width:204px">
					<option></option>
					<#list teachers as teacher>
						<option value="${teacher.id}" <#if teacher = (offering.wedTeacher)!>selected</#if>>${(teacher.fullName)!}</option>
					</#list>
				</select>
			</td>
			<td class="ta">${i18n.getMessage('wedTA')}:</td>
			<td>
				<select name="taWedTeacherId" id="taWedTeacherId" style="width:204px">
					<option></option>
				</select>
			</td>
		</tr>
		<tr>
			<td class="name">${i18n.getMessage('thuTeacher')}:</td>
			<td>
				<select name="thuTeacherId" id="thuTeacherId" style="width:204px">
					<option></option>
					<#list teachers as teacher>
						<option value="${teacher.id}" <#if teacher = (offering.thuTeacher)!>selected</#if>>${(teacher.fullName)!}</option>
					</#list>
				</select>
			</td>
			<td class="ta">${i18n.getMessage('thuTA')}:</td>
			<td>
				<select name="taThuTeacherId" id="taThuTeacherId" style="width:204px">
					<option></option>
				</select>
			</td>
		</tr>
		<tr>
			<td class="name">${i18n.getMessage('friTeacher')}:</td>
			<td>
				<select name="friTeacherId" id="friTeacherId" style="width:204px">
					<option></option>
					<#list teachers as teacher>
						<option value="${teacher.id}" <#if teacher = (offering.friTeacher)!>selected</#if>>${(teacher.fullName)!}</option>
					</#list>
				</select>
			</td>
			<td class="ta">${i18n.getMessage('friTA')}:</td>
			<td>
				<select name="taFriTeacherId" id="taFriTeacherId" style="width:204px">
					<option></option>
				</select>
			</td>
		</tr>
		<tr>
			<td class="name">${i18n.getMessage('satTeacher')}:</td>
			<td>
				<select name="satTeacherId" id="satTeacherId" style="width:204px">
					<option></option>
					<#list teachers as teacher>
						<option value="${teacher.id}" <#if teacher = (offering.satTeacher)!>selected</#if>>${(teacher.fullName)!}</option>
					</#list>
				</select>
			</td>
			<td class="ta">${i18n.getMessage('satTA')}:</td>
			<td>
				<select name="taSatTeacherId" id="taSatTeacherId" style="width:204px">
					<option></option>
				</select>
			</td>
		</tr>
		<tr>
			<td class="name">${i18n.getMessage('sunTeacher')}:</td>
			<td>
				<select name="sunTeacherId" id="sunTeacherId" style="width:204px">
					<option></option>
					<#list teachers as teacher>
						<option value="${teacher.id}" <#if teacher = (offering.sunTeacher)!>selected</#if>>${(teacher.fullName)!}</option>
					</#list>
				</select>
			</td>
			<td class="ta">${i18n.getMessage('sunTA')}:</td>
			<td>
				<select name="taSunTeacherId" id="taSunTeacherId" style="width:204px">
					<option></option>
				</select>
			</td>
		</tr>
		<tr>
			<td class="name1" style="vertical-align:top">${i18n.getMessage('comment')}:</td>
			<td colspan="3"><textarea name="comment" style="width:300px;height:80px">${offering.comment!}</textarea></td>
		</tr>
	</table>
	</fieldset>
	<table id="dataTable" cellspacing="5" cellpadding="0" align="center">
		<tr>
			<td class="name"></td>
			<td>
				<input type="submit" value="${i18n.getMessage('edit')}" class="button_style"/> 
				<input type="reset" value="${i18n.getMessage('reset')}" class="button_style"/> 
			</td>
		</tr>
	</table>	
</form>

<script>
$('error').hide();

printFollowUpBookCover = function() {
	window.open('offering/printFollowUpBookCover.sgt?ids=${offering.id}', '_blank');
}

printStudentPerformanceForm = function() {
	window.open('offering/printStudentPerformanceForm.sgt?ids=${offering.id}', '_blank');
}

exportSpeakingTestForm = function() {
	window.open('offering/exportSpeakingTestForm.sgt?id=${offering.id}', '_blank');				
}

exportCambridgeTestForm = function() {
	window.open('offering/exportCambridgeTestForm.sgt?id=${offering.id}', '_blank');				
}
</script>

<@ajax.select baseUrl="teachertasearch.view" source="monTeacherId" target="taMonTeacherId"
	parameters="teacherId={monTeacherId}" executeOnLoad=true defaultOptions="${(offering.monTATeacher.id)!}"/>
	
<@ajax.select baseUrl="teachertasearch.view" source="tueTeacherId" target="taTueTeacherId"
	parameters="teacherId={tueTeacherId}" executeOnLoad=true defaultOptions="${(offering.tueTATeacher.id)!}"/>
	
<@ajax.select baseUrl="teachertasearch.view" source="wedTeacherId" target="taWedTeacherId"
	parameters="teacherId={wedTeacherId}" executeOnLoad=true defaultOptions="${(offering.wedTATeacher.id)!}"/>
	
<@ajax.select baseUrl="teachertasearch.view" source="thuTeacherId" target="taThuTeacherId"
	parameters="teacherId={thuTeacherId}" executeOnLoad=true defaultOptions="${(offering.thuTATeacher.id)!}"/>
	
<@ajax.select baseUrl="teachertasearch.view" source="friTeacherId" target="taFriTeacherId"
	parameters="teacherId={friTeacherId}" executeOnLoad=true defaultOptions="${(offering.friTATeacher.id)!}"/>
	
<@ajax.select baseUrl="teachertasearch.view" source="satTeacherId" target="taSatTeacherId"
	parameters="teacherId={satTeacherId}" executeOnLoad=true defaultOptions="${(offering.satTATeacher.id)!}"/>
	
<@ajax.select baseUrl="teachertasearch.view" source="sunTeacherId" target="taSunTeacherId"
	parameters="teacherId={sunTeacherId}" executeOnLoad=true defaultOptions="${(offering.sunTATeacher.id)!}"/>